import sqlite3

# 連接到數據庫
conn = sqlite3.connect('network_system.db')
cursor = conn.cursor()

# 查詢所有用戶
cursor.execute("SELECT id, username, email, role, created_at FROM user ORDER BY id")
users = cursor.fetchall()

print("註冊用戶列表:")
print("-" * 80)
print(f"{'ID':<3} {'用戶名':<12} {'郵箱':<25} {'角色':<10} {'註冊時間'}")
print("-" * 80)

for user in users:
    user_id, username, email, role, created_at = user
    print(f"{user_id:<3} {username:<12} {email:<25} {role:<10} {created_at or '未知'}")

print(f"\n總共 {len(users)} 個用戶")

conn.close()
